import java.util.Arrays;

class Person{
    private String name;
    public int age;
    public double weight;

    public Person(){
        this("zhangsn");
        System.out.println("调用不带参数的构造方法");
    }
    public Person(String name){
        this.name=name;
        System.out.println("调用带一个参数的构造方法");
    }

    static {
        System.out.println("静态代码块！！！");
    }

    {
        System.out.println("实例代码块或构造代码块！！！");
    }

    public void setName(String name){
        this.name=name;
    }
    public String getName(){
        return this.name;
    }
}
public class TestDemo {
    //方法一
    public static void swap(int[] arr1,int[] arr2){
        //两个数组长度不同时，取较短的数组的长度，换一部分
        int len=arr1.length<arr2.length?arr1.length:arr2.length;
        for(int i=0;i<len;i++){
            int temp=arr1[i];
            arr1[i]=arr2[i];
            arr2[i]=temp;
        }
    }
    //方法二：将两个一维数组放在二维数组中交换
    public static void swap2(int[][] arr){
        int[] temp=arr[0];
        arr[0]=arr[1];
        arr[1]=temp;
    }
    public static void main(String[] args) {
        int[] arr1={1,2,3,4,5};
        int[] arr2={6,7,8,9,10};
        int[][] arr={arr1,arr2};
        System.out.println("==========交换前=========");
        /*System.out.println("arr1: "+Arrays.toString(arr1));
        System.out.println("arr2: "+Arrays.toString(arr2));*/
        System.out.println("arr1: "+Arrays.toString(arr[0]));
        System.out.println("arr2: "+Arrays.toString(arr[1]));
        System.out.println("==========交换后=========");
        /*swap(arr1,arr2);
        System.out.println("arr1: "+Arrays.toString(arr1));
        System.out.println("arr2: "+Arrays.toString(arr2));*/
        swap2(arr);
        System.out.println("arr1: "+Arrays.toString(arr[0]));
        System.out.println("arr2: "+Arrays.toString(arr[1]));
    }
    public static void main2(String[] args) {
        Person person=new Person();
    }
    public static void main1(String[] args) {
        Person person=new Person();
        person.setName("zhansan");
        System.out.println(person.getName());
    }
}
